package org.robotlegs.adapters
{
	import flash.system.ApplicationDomain;
	
	import org.robotlegs.core.IInjector;
	import org.swiftsuspenders.Injector;
	
	/**
	 * SwiftSuspender <code>IInjector</code> adpater - See: <a href="http://github.com/tschneidereit/SwiftSuspenders">SwiftSuspenders</a>
	 *
	 * @author tschneidereit
	 */
public class SwiftSuspendersInjector extends Injector implements IInjector
{
	protected static const XML_CONFIG:XML =
		<types>
			<type name='org.robotlegs.mvcs::Actor'>
				<field name='eventDispatcher'/>
			</type>
			<type name='org.robotlegs.mvcs::Command'>
				<field name='contextView'/>
				<field name='mediatorMap'/>
				<field name='eventDispatcher'/>
				<field name='injector'/>
				<field name='commandMap'/>
			</type>
			<type name='org.robotlegs.mvcs::Mediator'>
				<field name='contextView'/>
				<field name='mediatorMap'/>
				<field name='eventDispatcher'/>
			</type>
		</types>;
	
	public function SwiftSuspendersInjector(xmlConfig:XML = null)
	{
		if (xmlConfig)
		{
			for each (var typeNode:XML in XML_CONFIG.children())
			{
				xmlConfig.appendChild(typeNode);
			}
		}
		super(xmlConfig);
	}
	

	public function createChild(applicationDomain:ApplicationDomain = null):IInjector
	{
		var injector:SwiftSuspendersInjector = new SwiftSuspendersInjector();
		injector.setApplicationDomain(applicationDomain);
		injector.setParentInjector(this);
		return injector;
	}
	

	public function get applicationDomain():ApplicationDomain{return getApplicationDomain();}
	public function set applicationDomain(value:ApplicationDomain):void{setApplicationDomain(value);}

}
}